package com.filex.ads.common;

import android.support.annotation.NonNull;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.filex.ads.common.logging.Logger;


public class WebViews {


    public static void setDisableJSChromeClient(@NonNull final WebView webView) {
        webView.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onJsAlert(@NonNull final WebView view, @NonNull final String url,
                    @NonNull final String message, @NonNull final JsResult result) {
                Logger.d(message);
                result.confirm();
                return true;
            }

            @Override
            public boolean onJsConfirm(@NonNull final WebView view, @NonNull final String url,
                    @NonNull final String message, @NonNull final JsResult result) {
                Logger.d(message);
                result.confirm();
                return true;
            }

            @Override
            public boolean onJsPrompt(@NonNull final WebView view, @NonNull final String url,
                    @NonNull final String message, @NonNull final String defaultValue,
                    @NonNull final JsPromptResult result) {
                Logger.d(message);
                result.confirm();
                return true;
            }

            @Override
            public boolean onJsBeforeUnload(@NonNull final WebView view, @NonNull final String url,
                    @NonNull final String message, @NonNull final JsResult result) {
                Logger.d(message);
                result.confirm();
                return true;
            }
        });
    }
}
